/********************************************************************************************************************************
 * 《C ++ Primer》第五版中文版，读书笔记：按照书中的的示例源码和每一个小章节的课后习题，自己动手写代码实现，作为联系和测试。
 * Date: 2024-03-21 23:03
 * Author: dimon.chen 
 * EMali: 1181302388@qq.com 
 * 
 * 章节: 第一章 1.6 类
 *       1.6 书店程序
 * 
 ********************************************************************************************************************************/

#include <iostream>
#include "Sales_item.h"

int main(int argc, char *argv[]){
    Sales_item total; //store the sum value

    //read the fist item, ensure there is data to process
    if(std::cin >> total){
        Sales_item trans; //store the next item

        while(std::cin >> trans){
            if(trans.isbn() == total.isbn()){
                total += trans;
            }
            else{
                std::cout << "Last Sales item total sales data: " << total << std::endl;
                total = trans;
            }
        }

        //when while break, print out the last book sales
        std::cout << "Last Sales item total sales data: " << total << std::endl;
    }
    else{
        //no data in, Warning the reader
        std::cout << "No data ?!" << std::endl;
        return -1; //fail
    }
}